import request from '@/utils/request'

const baseURL = 'https://chatglm.cn/chatglm/assistant-api/v1'

const secret = {
  api_key: '575655421eb057e3',
  api_secret: '002eec12b04b0e8c541808ffb4ee9930',
}

const assistant_id = '6712595e574d5824ddf1c923'

// 获取token
export const getToken = () => request.post(`${baseURL}/get_token`, secret)

// 获取对话
export const getMessage = (prompt, conversation_id, token) =>
  request.post(
    `${baseURL}/stream_sync`,
    {
      assistant_id,
      prompt,
      conversation_id,
    },
    {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    },
  )
